package personal.domain.accounting;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table (name="month_end_account_balance")
@NamedQueries({
	@NamedQuery(name=MonthendAccountBalance.UPDATE_MONTHEND_ACC_BAL_SINCE, query="update MonthendAccountBalance set balance = balance + (:balDiff) where accountId=:accountId and calendarId>=:calendarId"),
	@NamedQuery(name= MonthendAccountBalance.GET_MONTHEND_ACC_BAL_FOR_CALENDARS, query="select accBal from MonthendAccountBalance accBal where accBal.calendarId in (:calendarIdList) order by accBal.calendarId asc")
})
public class MonthendAccountBalance implements Serializable {
	private static final long serialVersionUID = 1L;
	public static final String UPDATE_MONTHEND_ACC_BAL_SINCE = "MonthendAccountBalance.updateSince";
	public static final String GET_MONTHEND_ACC_BAL_FOR_CALENDARS = "MonthendAccountBalance.getForCalendars";
	private Long accountId;
	private Long calendarId;
	private BigDecimal balance;
	
	@Id
	@Column (name="account_id", length=11, unique=false, nullable=false, insertable=true, updatable=true)
	public Long getAccountId() {
		return accountId;
	}
	public void setAccountId(Long accountId) {
		this.accountId = accountId;
	}
	@Id
	@Column (name="calendar_id", length=11, unique=false, nullable=false, insertable=true, updatable=true)
	public Long getCalendarId() {
		return calendarId;
	}
	public void setCalendarId(Long calendarId) {
		this.calendarId = calendarId;
	}
	@Column (name="balance", unique=false, nullable=false, insertable=true, updatable=true)
	public BigDecimal getBalance() {
		return balance;
	}
	public void setBalance(BigDecimal balance) {
		this.balance = balance;
	}
	
}
